// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({
  env:'sudden-3gzfypks0b9196f8'
})

// 云函数入口函数
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()
  const db = cloud.database()
  const collectionDirection = db.collection('bannerinfo')
  const images = await collectionDirection.aggregate()
  .project({
    _id:0
  })
  .end()
  console.log(images)
  // let imageheader = images.data.map(v => {
  //   v.key = Math.random()
  //   return v
  // }).sort((a,b)=>{
  //   return a.key - b.key
  // }).slice(-5)
  // console.log("imageheader",imageheader)
  return {
    images
  }
}